﻿
#include <fstream>

#include "objectClass.h"


int load_anoObjClassList(const std::string& fname, AnoObjClass_List& ocl)
{
    std::ifstream inf(fname.c_str());

    if(inf.is_open()){
        int id;
        std::string oName, oColor;

        ocl.clear();

        inf >> id ;
        while(!inf.eof()) {
            inf >> oName >> oColor;
            AnoObjClass aoc;

            aoc.id = id;
            aoc.name = oName;
            aoc.color = oColor;

            int cbin;
            sscanf(oColor.c_str(), "%X", &cbin);
            aoc.r = (0xFF0000 & cbin) >> 16;
            aoc.g = (0x00FF00 & cbin) >> 8;
            aoc.b = 0x0000FF & cbin;

            ocl.push_back(aoc);
            inf >> id ;
        }
    } else {
       printf("Can't find class define file!\n");
       return -1;
    }

    inf.close();
    return 0;
}


